﻿Jxstar.currentPage = function() {
	var config = {param:{},initpage:function(page, define){},eventcfg:{}};
	
	var auditData = Jxstar.findComboData('audit');
	var items = [{
		height: '97%',
		width: '97%',
		border: false,
		layout: 'form',
		style: 'padding:10px;',
		items: [{
			anchor:'100%',
			border: false,
			layout:'column',
			autoHeight:true,
			items:[{
				border:false,
				columnWidth:0.495,
				layout:'form',
				style: 'padding-left:10px;',
				items:[
					{xtype:'textfield', fieldLabel:'合同编号', name:'sj_balance__contract_code', readOnly:true, anchor:'100%', maxLength:20},
					{xtype:'textfield', fieldLabel:'合同名称', name:'sj_balance__contract_name', readOnly:true, anchor:'100%', maxLength:100},
					{xtype:'textfield', fieldLabel:'项目名称', name:'sj_balance__project_name', readOnly:true, anchor:'100%', maxLength:100},
					{xtype:'textfield', fieldLabel:'施工单位名称', name:'sj_balance__provider_name', readOnly:true, anchor:'100%', maxLength:50},
					{xtype:'textfield', fieldLabel:'送审部门', name:'sj_balance__dept_name', readOnly:true, anchor:'100%', maxLength:50},
					{xtype:'numberfield', decimalPrecision:6, fieldLabel:'送审金额(万元)', name:'sj_balance__send_money', defaultval:'0', readOnly:true, anchor:'100%', maxLength:12},
					{xtype:'numberfield', decimalPrecision:6, fieldLabel:'审减额(万元)', name:'sj_balance__money_del', defaultval:'0', readOnly:true, anchor:'100%', maxLength:12},
					{xtype:'numberfield', decimalPrecision:6, fieldLabel:'最终审定金额(万元)', name:'sj_balance__check_money', defaultval:'0', allowBlank:false, labelStyle:'color:#0000FF;', labelSeparator:'*', anchor:'100%', maxLength:12},
					{xtype:'datefield', fieldLabel:'审签日期', name:'sj_balance__check_date', format:'Y-m-d', allowBlank:false, labelStyle:'color:#0000FF;', labelSeparator:'*', anchor:'100%'},
					{xtype:'textfield', fieldLabel:'审计编制单位', name:'sj_balance__check_dept', allowBlank:false, labelStyle:'color:#0000FF;', labelSeparator:'*', anchor:'100%', maxLength:50},
					{xtype:'hidden', fieldLabel:'施工单位ID', name:'sj_balance__provider_id', anchor:'100%'},
					{xtype:'hidden', fieldLabel:'项目ID', name:'sj_balance__project_id', anchor:'100%'},
					{xtype:'hidden', fieldLabel:'主键', name:'sj_balance__sj_balanceid', anchor:'100%'}
				]
			},{
				border:false,
				columnWidth:0.495,
				layout:'form',
				style: 'padding-left:10px;',
				items:[
					{xtype:'combo', fieldLabel:'记录状态', name:'sj_balance__auditing1', defaultval:'0',
						anchor:'100%', readOnly:true, editable:false,
						store: new Ext.data.SimpleStore({
							fields:['value','text'],
							data: auditData
						}),
						emptyText: jx.star.select,
						mode: 'local',
						triggerAction: 'all',
						valueField: 'value',
						displayField: 'text',
						value: auditData[0][0]},
					{xtype:'textfield', fieldLabel:'项目编号', name:'sj_balance__project_code', readOnly:true, anchor:'100%', maxLength:20},
					{xtype:'textfield', fieldLabel:'项目负责人', name:'sj_balance__project_user', readOnly:true, anchor:'100%', maxLength:20},
					{xtype:'numberfield', decimalPrecision:6, fieldLabel:'合同金额(万元)', name:'sj_balance__contract_money', defaultval:'0', readOnly:true, anchor:'100%', maxLength:12},
					{xtype:'datefield', fieldLabel:'送审日期', name:'sj_balance__send_date', format:'Y-m-d', anchor:'100%', readOnly:true},
					{xtype:'textfield', fieldLabel:'送审金额大写', name:'sj_balance__send_money1', readOnly:true, anchor:'100%', maxLength:50},
					{xtype:'numberfield', decimalPrecision:6, fieldLabel:'审增额(万元)', name:'sj_balance__money_add', defaultval:'0', readOnly:true, anchor:'100%', maxLength:12},
					{xtype:'textfield', fieldLabel:'审定金额大写', name:'sj_balance__check_money1', readOnly:true, anchor:'100%', maxLength:50},
					{xtype:'textfield', fieldLabel:'审计人', name:'sj_balance__check_user', readOnly:true, anchor:'100%', maxLength:20},
					{xtype:'textfield', fieldLabel:'结算审计编号', name:'sj_balance__sj_code', anchor:'100%', maxLength:20},
					{xtype:'hidden', fieldLabel:'合同ID', name:'sj_balance__contract_id', anchor:'100%'},
					{xtype:'hidden', fieldLabel:'项目负责人ID', name:'sj_balance__project_userid', anchor:'100%'},
					{xtype:'hidden', fieldLabel:'送审部门ID', name:'sj_balance__dept_id', anchor:'100%'},
					{xtype:'hidden', fieldLabel:'审计人ID', name:'sj_balance__check_userid', anchor:'100%'}
				]
			}
			]
		},{
			anchor:'100%',
			border: false,
			layout:'column',
			autoHeight:true,
			items:[{
				border:false,
				columnWidth:0.99,
				layout:'form',
				style: 'padding-left:10px;',
				items:[
					{xtype:'textarea', fieldLabel:'说明事项', name:'sj_balance__check_memo', width:'100%', height:48, maxLength:200}
				]
			}
			]
		}]
	}];
	
	config.param = {
		items: items,
		funid: 'sj_balance_get'
	};

	config.initpage = function(formNode){		var event = formNode.event;				//扩展保存前事件		event.on('beforesave', function(event) {			var form = event.form;			//取送审金额的大写			var send_money = form.get("sj_balance__send_money");			var send_money1 = parseFloat(send_money) * 10000;			form.set("sj_balance__send_money1", JxUtil.numBigMoney(send_money1));						//取审定金额的大写			var check_money = form.get("sj_balance__check_money");			var check_money1 = parseFloat(check_money) * 10000;			form.set("sj_balance__check_money1", JxUtil.numBigMoney(check_money1));						return true;		});				//根据审定金额计算增减值		var form = formNode.page.getForm();		var fcheck = form.findField('sj_balance__check_money');		fcheck.on('change', function(field, newValue, oldValue){			var check_money = newValue;			var send_money = form.get("sj_balance__send_money");						var dx_money = parseFloat(send_money).toFixed(2) - parseFloat(check_money).toFixed(2);			if (dx_money > 0) {				form.set("sj_balance__money_add", 0);				form.set("sj_balance__money_del", dx_money);			} else {				form.set("sj_balance__money_add", -dx_money);				form.set("sj_balance__money_del", 0);			}						//取审定金额的大写			var check_money1 = parseFloat(check_money) * 10000;			form.set("sj_balance__check_money1", JxUtil.numBigMoney(check_money1));		});	};			config.eventcfg = {		//初始化页面数据		initOther : function() {			var myform = this.form;			var chkdate = myform.get("sj_balance__check_date");			if (chkdate == null || chkdate.length == 0) {				myform.set("sj_balance__check_date", JxDefault.getToday());			}						var username = myform.get("sj_balance__check_user");			if (username == null || username.length == 0) {				myform.set("sj_balance__check_user", JxDefault.getUserName());				myform.set("sj_balance__check_userid", JxDefault.getUserId());			}						var check_money = myform.get("sj_balance__check_money");			var send_money = myform.get("sj_balance__send_money");			if (check_money == null || check_money == '0') {				myform.set("sj_balance__check_money", send_money);								//取送审金额的大写				var send_money1 = JxUtil.numBigMoney(parseFloat(send_money) * 10000);				myform.set("sj_balance__send_money1", send_money1);				myform.set("sj_balance__check_money1", send_money1);								myform.set("sj_balance__money_add", 0);				myform.set("sj_balance__money_del", 0);			}		}	};
	
	return new Jxstar.FormNode(config);
}